﻿<extend name="Public/base" />
<!-- 界面样式 -->
<block name="style">
    <style>
        .logo_img {
            margin-top: 60px;
        }

            .logo_img img {
                width: 200px;
            }
    </style>
</block>
<block name="body">


    <div class="weui_msg">
        <div class="weui_icon_area logo_img">
            <img src='__IMG__/logo-big.png' />
        </div>
        <div class="weui_text_area">
            <form action="{:U('register')}" method="post" id="_login_form" name="_login_form">

                <div class="weui_cells weui_cells_form">
                    <div class="weui_cell">
                        <div class="weui_cell_hd"><label class="weui_label">手机号</label></div>
                        <div class="weui_cell_bd weui_cell_primary">
                            <input id='mobile' name='mobile' class="weui_input" type="tel" placeholder="请输入手机号码">
                        </div>
                    </div>
                    <div class="weui_cell">
                        <div class="weui_cell_hd"><label class="weui_label">登录密码</label></div>
                        <div class="weui_cell_bd weui_cell_primary">
                            <input id='password' name='password' class="weui_input" type="password" placeholder="请输入登录密码">
                        </div>
                    </div> 
                    <div class="weui_cell">
                        <div class="weui_cell_hd"><label class="weui_label">确认密码</label></div>
                        <div class="weui_cell_bd weui_cell_primary">
                            <input id='password2' name='password2' class="weui_input" type="password" placeholder="请确认登录密码">
                        </div>
                    </div> 
                </div>

               

            </form>

        </div>
        <div class="weui_opr_area">
            <p class="weui_btn_area">
                <button id="_login_btn" class="weui_btn weui_btn_primary">确定注册</button>

                <a href="{:U('login')}" style=" width: 48%;" class="weui_btn weui_btn_mini weui_btn_primary">返回登录</a>
                <a href="{:U('main')}" style=" width: 48%;" class="weui_btn weui_btn_mini weui_btn_default">浏览首页</a>

            </p>
        </div>

    </div>


</block>
<!-- 脚本代码必须写在   block name="script" 标签里 -->
<block name="script">
    <!-- 引入JQ-WEUI插件【按需引入】 -->
    <script src="__THEMES__/js/jquery-weui.min.js?v={:C('CURRENT_FILE_VERSION')}"></script>
    <script type="text/javascript">
        $(function () {
            
            //给提交按钮绑定 touchend 时间。 如果用 click时间会有300-400毫秒的触发延时
            $("#_login_btn").on('touchend', function (e) {
                e.preventDefault();//阻止“默认行为”

                var _mobile=$.trim($('#mobile').val());
                if(_mobile=="")
                {
                    $.toast("请输入手机号码", "forbidden");
                    return;
                }

                var _password=$.trim($('#password').val());
                if(_password=="")
                {
                    $.toast("请输入登录密码", "forbidden");
                    return;
                }

                 var _password2=$.trim($('#password2').val());
                if(_password2=="")
                {
                    $.toast("请确认登录密码", "forbidden");
                    return;
                }

            
                if(_password2 !=_password)
                {
                    $.toast("2次密码输入不一致", "forbidden");
                    return;
                }

                var data = $('#_login_form').serialize();
                var url = $('#_login_form').attr('action');

                $.showLoading('注册中...');

                $.ajax({
                    url:url,
                    data:data,
                    type:'POST',
                    dataType:'json',
                    success: function (data) {
                        $.hideLoading();

                        if(data.status<1){
                            $.toast(data.info, "forbidden");
                            $('#_login_btn').html('登 陆');
                            $('#_login_btn').removeAttr('disabled');
                        }else{
                            $.toast(data.info);
                            $('#_login_btn').html('登陆成功,正在跳转...');
                            setTimeout(function(){
                                window.location.href=data.url;
                            },900);
                            return;
                        }
                    },
                    error: function () {
                        $.hideLoading();
                        $.toast(data.info, "网络请求失败"); 
                        $('#_login_btn').html('登 陆');
                        $('#_login_btn').removeAttr('disabled');
                    },complete:function(){
                       
                    }
                });

            });
             


        });

    </script>
</block>